﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSqlAnalyzer.util
{
	// Token: 0x02000072 RID: 114
	public class functionChecker
	{
		// Token: 0x060002C6 RID: 710 RVA: 0x002F83F4 File Offset: 0x002F65F4
		private functionChecker()
		{
		}

		// Token: 0x060002C7 RID: 711 RVA: 0x002F83FC File Offset: 0x002F65FC
		public static bool isBuiltInFunction(string inputString, EDbVendor dbvendor, string dbVersion)
		{
			if (inputString == null || inputString.Trim().Equals(""))
			{
				return false;
			}
			string item = inputString.ToUpper();
			functionList builtInFunctionList = functionListFactory.Instance.getBuiltInFunctionList(dbvendor, dbVersion);
			if (builtInFunctionList == null)
			{
				throw new ArgumentException("Can't get available built-in function list");
			}
			return builtInFunctionList.BuiltInFunctionList.Contains(item);
		}

		// Token: 0x060002C8 RID: 712 RVA: 0x002F844C File Offset: 0x002F664C
		public static string getBuiltInFunctionList(EDbVendor dbvendor, string dbVersion)
		{
			functionList builtInFunctionList = functionListFactory.Instance.getBuiltInFunctionList(dbvendor, dbVersion);
			if (builtInFunctionList == null)
			{
				throw new ArgumentException("Can't get available built-in function list");
			}
			List<string> builtInFunctionList2 = builtInFunctionList.BuiltInFunctionList;
			if (builtInFunctionList2 != null)
			{
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < builtInFunctionList2.Count; i++)
				{
					if (i < builtInFunctionList2.Count - 1)
					{
						stringBuilder.Append(builtInFunctionList2[i]).Append(",");
					}
					else
					{
						stringBuilder.Append(builtInFunctionList2[i]);
					}
				}
				return stringBuilder.ToString();
			}
			return null;
		}

		// Token: 0x060002C9 RID: 713 RVA: 0x002F84D0 File Offset: 0x002F66D0
		public static string compareBuiltInFunctionList(EDbVendor dbvendor1, string dbVersion1, EDbVendor dbvendor2, string dbVersion2)
		{
			functionList builtInFunctionList = functionListFactory.Instance.getBuiltInFunctionList(dbvendor1, dbVersion1);
			functionList builtInFunctionList2 = functionListFactory.Instance.getBuiltInFunctionList(dbvendor2, dbVersion2);
			if (builtInFunctionList == null || builtInFunctionList2 == null)
			{
				throw new ArgumentException("Can't get available built-in function list");
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			List<string> list3 = new List<string>();
			list3.AddRange(builtInFunctionList.BuiltInFunctionList);
			CollectionUtil<string>.retainAll(list3, builtInFunctionList2.BuiltInFunctionList);
			list.AddRange(builtInFunctionList.BuiltInFunctionList);
			list2.AddRange(builtInFunctionList2.BuiltInFunctionList);
			CollectionUtil<string>.removeAll(list, list3);
			CollectionUtil<string>.removeAll(list2, list3);
			for (int i = 0; i < list2.Count; i++)
			{
				list.Add("-" + list2[i]);
			}
			list.Sort(new functionChecker.ComparatorAnonymousInnerClass());
			StringBuilder stringBuilder = new StringBuilder();
			for (int j = 0; j < list.Count; j++)
			{
				stringBuilder.Append(list[j]);
				if (j < list.Count - 1)
				{
					stringBuilder.Append(",");
				}
			}
			return stringBuilder.ToString();
		}

		// Token: 0x060002CA RID: 714 RVA: 0x002F85E1 File Offset: 0x002F67E1
		public static List<string> getAvailableDbVersions(EDbVendor dbvendor)
		{
			return functionListFactory.Instance.getAvailableDbVersions(dbvendor);
		}

		// Token: 0x060002CB RID: 715 RVA: 0x002F85EE File Offset: 0x002F67EE
		public static bool containsDbVersion(EDbVendor dbvendor, string dbVersion)
		{
			return functionListFactory.Instance.containsDbVersion(dbvendor, dbVersion);
		}

		// Token: 0x0400107E RID: 4222
		private const string COMMA = ",";

		// Token: 0x0400107F RID: 4223
		private const string MINUS = "-";

		// Token: 0x02000433 RID: 1075
		private class ComparatorAnonymousInnerClass : IComparer<string>
		{
			// Token: 0x0600295C RID: 10588 RVA: 0x0033E31C File Offset: 0x0033C51C
			public virtual int Compare(string str1, string str2)
			{
				if (!str1.StartsWith("-", StringComparison.Ordinal))
				{
					str1 = "-" + str1;
				}
				if (!str2.StartsWith("-", StringComparison.Ordinal))
				{
					str2 = "-" + str2;
				}
				return string.Compare(str1, str2, StringComparison.OrdinalIgnoreCase);
			}
		}
	}
}
